Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
A lightweight Dependency Injection library. Using es6 and other features, remove unnecessary concepts, easy and convenient to use.
A lightweight Dependency Injection library. Using es6 and other features, remove unnecessary concepts, easy and convenient to use.
npm i power-di --save
import { IocContext } from 'power-di'
class AService { }
// default instance, you can also new IocContext to get a instance.
const context = IocContext.DefaultInstance
context.register(AService)
const aService = context.get(AService) // a instance of AService
class AService { }
const context = IocContext.DefaultInstance
context.register(AService, 'XService') // key need a string or class, e.g super class or whatever class.
context.get('XService')
import { getDecorators } from '../helper'
const {
register, append, inject, lazyInject, registerSubClass, lazyInjectSubClass
} = getDecorators() // you can provider a iocContext for this method.
@register()
class AService { }
class SomeClass {
@inject() // set right now
private aService: AService
@lazyInject() // set when using
private bService: AService
}
context.get(AService)
import { IocProvider, Component } from 'power-di/react'
@register()
class AService { }
class TestComponent extends Component<{}, {}> {
componentWillMount() {
this.GetComponent(AService)
}
render(): any {
return null
}
}
// parent component, the IocProvider is not necessary.
<IocProvider context={context}>
<TestComponent />
</IocProvider>
class A { }
@register(undefined, { regInSuperClass: true })
class B extends A { }
@registerSubClass() // the abbreviation of above
class C extends A { }
@append(A)
class D { }
class LITestService {
@lazyInject({ type: A, subClass: true }) // need type when inject subClass, Reflect cannot get the type.
public testService1: A[] // [b, c, d], the type is A[] or any[] (D may be not instance of A)
@lazyInjectSubClass({ type: A }) // need type when inject subClass, Reflect cannot get the type.
public testService2: A[] // the abbreviation of above
}
1.4.17 / 2019-02-26
FAQs
A lightweight Dependency Injection library. Using es6 and other features, remove unnecessary concepts, easy and convenient to use.
The npm package power-di receives a total of 337 weekly downloads. As such, power-di popularity was classified as not popular.
We found that power-di demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.